﻿using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using XYAC.Framework.MonitorTireMaterialOnline.DataExporter;
using XYAC.Framework.MonitorTireMaterialOnline.OracleRemoteDB;

namespace XYAC.Framework.MonitorTireMaterialOnline.Entities
{
    public class SemiSteelSideInspectionReport : ReportEntityBase
    {
        public SemiSteelSideInspectionReport()
        {
            LastSyncDate = DateTime.Now;
        }
        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int ID { get; set; }
        public override bool? IsDeleted { get; set; }
        public int UserId { get; set; }
        /// <summary>
        /// 补偿系数
        /// </summary>
        public double CompensationCoefficient { get; set; }
        /// <summary>
        /// 批次号
        /// </summary>
        public int BatchNo { get; set; }

        /// <summary>
        /// 规格号
        /// </summary>
        public string SpecName { get; set; }
        /// <summary>
        /// 总面积
        /// </summary>
        public double TotalArea { get; set; }
        public double TotalLeftArea { get; set; }
        public double TotalRightArea { get; set; }
        public double MeasureArea { get; set; }
        public double MeasureLeftArea { get; set; }
        public double MeasureRightArea { get; set; }

        /// <summary>
        /// 总宽标准
        /// </summary>
        public double TotalWidth_Stable { get; set; }

        /// <summary>
        /// 总宽扫描
        /// </summary>
        public double TotalWidth_Scan { get; set; }

        /// <summary>
        /// 总宽对称性
        /// </summary>
        public double TotalWidth_Symmetry { get; set; }
        /// <summary>
        /// 胎侧厚度标准
        /// </summary>
        public double SidewallThickness_Stable { get; set; }

        /// <summary>
        /// 胎侧厚度扫描-左
        /// </summary>
        public double SidewallThickness_ScanLeft { get; set; }
        /// <summary>
        /// 胎侧厚度扫描-右
        /// </summary>
        public double SidewallThickness_ScanRight { get; set; }

        /// <summary>
        /// 胎侧厚度对称性
        /// </summary>
        public double SidewallThickness_Symmetry { get; set; }
        /// <summary>
        /// RC胶厚度标准
        /// </summary>
        public double RCRubberThickness_Stable { get; set; }
        /// <summary>
        /// RC胶厚度扫描左
        /// </summary>
        public double RCRubberThickness_ScanLeft { get; set; }
        /// <summary>
        /// RC胶厚度扫描右
        /// </summary>
        public double RCRubberThickness_ScanRight { get; set; }
        /// <summary>
        /// RC胶厚度对称性
        /// </summary>
        public double RCRubberThickness_Symmetry { get; set; }


        /// <summary>
        /// 断面形状
        /// </summary>
        public string? CrossSectionShape { get; set; }
        /// <summary>
        /// 机台编号
        /// </summary>
        public string? EqpNo { get; set; }
        /// <summary>
        /// 最后同步时间
        /// </summary>
        public DateTime? LastSyncDate { get; set; }
        /// <summary>
        /// 同步状态
        /// </summary>
        public Boolean SyncState { get; set; } = false;



        /// <summary>
        /// 将 SemiSteelSideInspectionReport 实例转换为 YB_PROCESS_STEP 实例。
        /// </summary>
        /// <param name="report">要转换的 SemiSteelSideInspectionReport 实例。</param>
        /// <returns>转换后的 YB_PROCESS_STEP 实例。</returns>
        public override YB_PROCESS_STEP ToYB_PROCESS_STEP()
        {
            var dataFile = DataFile.FromSpecVal(this.SpecVal);

            var processStep = new YB_PROCESS_STEP
            {
                // 映射 SemiSteelSideInspectionReport 的字段到 RECORD16 至 RECORD32
                RECORD190 = this.CompensationCoefficient.ToString("F2"),
                RECORD160 = this.AreaPencent.ToString(),
                PLAN_ID = this.BatchNo.ToString(),
                PART_NUMBER = this.SpecName,
                RECORD122 = this.TotalArea.ToString("F2"),
                RECORD123 = this.MeasureArea.ToString("F2"),
                RECORD124 = this.TotalLeftArea.ToString("F2"),
                RECORD125 = this.MeasureLeftArea.ToString("F2"),
                RECORD126 = this.TotalRightArea.ToString("F2"),
                RECORD127 = this.MeasureRightArea.ToString("F2"),
                RECORD128 = this.TotalWidth_Stable.ToString("F2"),
                RECORD129 = this.TotalWidth_Scan.ToString("F2"),
                RECORD161 = this.TotalWidth_Symmetry.ToString("F2"),
            };
            this.UpdateProcessStep(processStep, dataFile);

            return processStep;
        }

    }
}
